package com.room.controller.person;

import com.room.pojo.DormResult;
import com.room.pojo.PersonEdit;
import com.room.pojo.User;
import com.room.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @创建人 lin
 * @创建时间 2019/10/16
 * @描述
 */
@RestController
@RequestMapping("/email/manager")
public class PersonController {

    @Autowired
    UserService userService;

    /**
     * 修改用户的邮箱和联系方式
     * @param personEdit
     * @return
     */
    @RequestMapping(value = "/edit",method = RequestMethod.PUT)
    public DormResult updatePerson(PersonEdit personEdit){
        User user = new User();
        if(personEdit == null){
            return DormResult.error("数据不能为空");
        }
        user.setUsername(personEdit.getUsername());
        user.setEmail(personEdit.getEmail());
        user.setPhone(personEdit.getPhone());
        userService.updateUserByUsername(user);
        return DormResult.ok("修改成功");
    }
}
